package com.example.e_comm.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("roles")
public class Role {

    public String getRoleKey() {
        return roleKey;
    }
    public String getName() {
        return name;
    }
    public String getDescription() {
        return description;
    }
    public Long getId() {
        return id;
    }

public void setPermissions(List<Permission> permissions) {
    this.permissions = permissions;
}

    public LocalDateTime getCreateTime() {
        return createTime;
    }
//    13-32修改RoleController添加

    public Role (long id, String name, String description, String roleKey, Integer status){
       this.id = id;
       this.name = name;
       this.description = description;
       this.roleKey = roleKey;
       this.status = 1;
       this.deleted = 0;
       this.createTime = LocalDateTime.now();
       this.updateTime = LocalDateTime.now();
    }



    @TableId(type = IdType.AUTO)
    private long id;
    private String name;//角色名
    private String description;//描述

    @TableField(value = "role_key")
    private String roleKey;//角色标识，用于权限校验
    private Integer status;

    @TableLogic(value = "0",delval = "1")
    private Integer deleted;//0：没有删除 1:逻辑删除

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime= LocalDateTime.now();
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime = LocalDateTime.now();
//    关联关系,根据角色进行分配权限
    @TableField(exist = false)
    private List<Permission> permissions;//角色权限列表

    public Role() {
        
    }

    public Role(long l, String testAdmin, String 测试管理员, String s, int i, int i1, LocalDateTime now, LocalDateTime now1, Object o) {
    }
}
